<template>
	<div>
		<el-dialog :title="$t('action.add')" width="70%" class="icon-dialog" :visible.sync="show" @open="open" :before-close="closeForm" append-to-body>
			<el-form :size="size" ref="form" :model="form" :rules="rules" :label-width="$store.getters.device !== 'mobile'?'16%':'90px'">
 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.I118_message_id')" prop="message_id">
							<el-input v-model="form.message_id" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.I118_message_id')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.I118_name')" prop="name">
							<el-input v-model="form.name" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.I118_name')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
				   <el-col :span="24">
                        <el-form-item :label="$t('field.I118_type')" prop="type">
                            <el-select style="width:100%" v-model="form.type" :size="size" clearable filterable :placeholder="$t('system.pleaseSelect')">
                                <el-option key="0"  label="文本" :value="1"></el-option>
                                <el-option key="1"  label="富文本" :value="2"></el-option>
                            </el-select>
                        </el-form-item>
                   </el-col>
				 </el-row>
	 				 <el-row >
				   <el-col :span="24">
                        <el-form-item :label="$t('field.I118_use_way')" prop="use_way">
                            <el-select style="width:100%" v-model="form.use_way" :size="size" clearable filterable :placeholder="$t('system.pleaseSelect')">
                                <el-option key="0"  label="admin" :value="1"></el-option>
                                <el-option key="1"  label="app" :value="2"></el-option>
                                <el-option key="2"  label="both" :value="3"></el-option>
                            </el-select>
                        </el-form-item>
                   </el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.I118_controller')" prop="controller">
							<el-input v-model="form.controller" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.I118_controller')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.I118_original_id')" prop="original_id">
							<el-input v-model="form.original_id" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.I118_original_id')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.I118_language_zh')" prop="language_zh">
							<el-input v-model="form.language_zh" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.I118_language_zh')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.I118_language_en')" prop="language_en">
							<el-input v-model="form.language_en" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.I118_language_en')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.I118_language_ja')" prop="language_ja">
							<el-input v-model="form.language_ja" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.I118_language_ja')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.I118_language_01')" prop="language_01">
							<el-input v-model="form.language_01" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.I118_language_01')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.I118_language_02')" prop="language_02">
							<el-input v-model="form.language_02" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.I118_language_02')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.I118_language_03')" prop="language_03">
							<el-input v-model="form.language_03" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.I118_language_03')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.I118_language_04')" prop="language_04">
							<el-input v-model="form.language_04" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.I118_language_04')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.I118_language_05')" prop="language_05">
							<el-input v-model="form.language_05" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.I118_language_05')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.I118_language_06')" prop="language_06">
							<el-input v-model="form.language_06" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.I118_language_06')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button :size="size" :loading="loading" type="primary" @click="submit" >
					<span v-if="!loading">{{$t('system.confirm')}}</span>
					<span v-else>{{$t('system.submitting')}}</span>
				</el-button>
				<el-button :size="size" @click="closeForm">{{$t('system.cancel')}}</el-button>
			</div>
		</el-dialog>
	</div>
</template>
<script>
import { add } from '@/api/admin/i118'



export default {
	name:'i118add',
	components: {
	   	   
	},
	props: {
		show: {
			type: Boolean,
			default: false
		},
		size: {
			type: String,
			default: 'small'
		},
		querys:{
			type:Object,
		},
	},
	data(){
		return {
		    dialog:{
			},
			
			form: {
			   message_id:'',
			   name:'',
			   type:1,
			   use_way:3,
			   controller:'',
			   original_id:'',
			   language_zh:'',
			   language_en:'',
			   language_ja:'',
			   language_01:'',
			   language_02:'',
			   language_03:'',
			   language_04:'',
			   language_05:'',
			   language_06:'',
			   create_time:'',
			},
		    initial:{},   
			loading:false,
			rules: {
			}
		}
	},
	watch:{
		show(val){
			if(val){
			}
		}
	},
	methods: {
		open(){
		  if(this.querys){
		  }
		},
		submit(){
			this.$refs['form'].validate(valid => {
				if(valid) {
					this.loading = true
					add(this.form).then(res => {
						if(res.status == 200){
							this.$message({message: this.$t('system.success'), type: 'success'})
							this.$emit('refresh_list')
							this.closeForm()
						}
					}).catch(()=>{
						this.loading = false
					})
				}
			})
		},
		closeForm(){
			this.$emit('update:show', false)
			this.loading = false
			if (this.$refs['form']!==undefined) {
				this.$refs['form'].resetFields()
			}
		},
	}
}
</script>
<style scoped lang="scss">
@import '@/assets/scss/common.scss'
</style>
